import 'package:stacked/stacked.dart';
import 'package:vista/shared/models/tutorial_video.dart';
import 'package:vista/shared/services/tutorial_video_service.dart';

/// 技能课程视图模型
/// 管理技能课程页面的数据和状态
class SkillsClassViewModel extends BaseViewModel {
  final TutorialVideoService _tutorialVideoService;

  SkillsClassViewModel(this._tutorialVideoService);

  List<TutorialVideo> _videos = [];
  List<TutorialVideo> get videos => _videos;

  /// 初始化数据
  Future<void> initialize() async {
    setBusy(true);
    try {
      await _loadVideos();
    } finally {
      setBusy(false);
    }
  }

  /// 加载视频列表
  Future<void> _loadVideos() async {
    _videos = await _tutorialVideoService.getAllVideos();
    notifyListeners();
  }

  /// 刷新数据
  Future<void> refresh() async {
    await initialize();
  }
}
